/********************************************************/
/*	Copyright (C) 2016 Gong Li Bin			*/
/*	Project:	GlbCloud			*/
/*	Author:		gong_libin			*/
/*	Date:		2012_02_20			*/
/*	File:		MrUdp.h				*/
/********************************************************/

#ifndef _MRUDP_H
#define	_MRUDP_H

#include "MrNet.h"
#define __FAVOR_BSD
#include <netinet/udp.h>

class CMrUdp : public CMrNet
{
public:
	CMrUdp();
	virtual ~CMrUdp();

	void MrUdpReset();
	void* MrUdpGetAddr();
	void MrUdpSetAddr(void* pAddr);
	void MrUdpSetAddr(char* pszUrl);
	int MrUdpConnect(char* pszUrl);
	int MrUdpConnect(struct sockaddr_in* pstAddr);
	int MrUdpConnect(char* pszAddr, char* pszPort);
	int MrUdpRead(UCHAR* puszPacket, UINT uiLength);
	int MrUdpWrite(UCHAR* puszPacket, UINT uiLength);

	virtual int MrNetSend(UCHAR* puszPacket, int iLength);
	virtual int MrNetRecv(UCHAR* puszPacket, int iLength);
	virtual int MrNetSendAll(UCHAR* puszPacket, int iLength);
	virtual int MrNetRecvAll(UCHAR* puszPacket, int iLength);

	virtual int MrNetInitSend(char* pszUrl);
	virtual int MrNetInitRecv(char* pszUrl);
	virtual int MrNetInitSend(struct sockaddr_in* pstAddr);
	virtual int MrNetInitRecv(struct sockaddr_in* pstAddr);
	virtual int MrNetInitSend(char* pszAddr, char* pszPort);
	virtual int MrNetInitRecv(char* pszAddr, char* pszPort);

private:
	struct sockaddr_in m_stAddr;

};

#endif /* _MRUDP_H */
